<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.2.1/axios.js"></script>
    <script src="./node_modules/nprogress/nprogress.js"></script>
    <link rel="stylesheet" href="./node_modules/nprogress/nprogress.css" />
</head>
<body>
    <button>获取按钮</button>
    <script>
        let btn= document.querySelector('button');
        let loadbox= document.querySelector('.loading');

        // console.log(NProgress.start());
        axios.interceptors.request.use(config=>{
            // 显示loading
            NProgress.start();
            return config;
        })

        axios.interceptors.response.use(res=>{
            // 关闭loading
            NProgress.done();
            return res;
        })

        btn.onclick= function(){
            axios({
                url:"http://localhost:3000/users"
            }).then(val=>{
                console.log(val);
            })
        }
    </script>
</body>
</html>